﻿using System;
using System.Collections.Generic;
using System.Text;
using TarreOA.TarreOAModels;
using TarreOA.TarreOADAL;

namespace TarreOA.TarreOABLL
{
    public class UserCalendarArrangetbService
    {
         /// <summary>
        /// 将日程安排信息保存在指定数据表中
        /// </summary>
        /// <param name="caTitle"></param>
        /// <param name="caContent"></param>
        /// <param name="caStartTime"></param>
        /// <param name="caEndTime"></param>
        /// <param name="caIntervalMinute"></param>
        /// <param name="caDate"></param>
        /// <param name="caType"></param>
        /// <param name="UserLoginName"></param>
        /// <returns></returns>
        public int[] saveUserCalendarArrangeInfo(string caTitle, string caContent, string caStartTime, string caEndTime,
            int caIntervalMinute, DateTime caDate, string caType, string userLoginName)
        {
            UserCalendarArrangetbDAO ucatbDAO = new UserCalendarArrangetbDAO();
            return ucatbDAO.saveUserCalendarArrangeInfo(caTitle, caContent, caStartTime, caEndTime, caIntervalMinute, caDate,
                caType, userLoginName);
        }

        /// <summary>
        /// 根据编号更改日程安排的信息
        /// </summary>
        /// <param name="caId"></param>
        /// <param name="caTitle"></param>
        /// <param name="caContent"></param>
        /// <param name="caStartTime"></param>
        /// <param name="caEndTime"></param>
        /// <param name="caIntervalMinute"></param>
        /// <param name="caDate"></param>
        /// <param name="caType"></param>
        /// <param name="UserLoginName"></param>
        /// <returns></returns>
        public bool UpdateCalendarArrangeInfoById(int caId, string caTitle, string caContent, string caStartTime, string caEndTime,
             int caIntervalMinute, string caType)
        {
            bool state = false;
            UserCalendarArrangetbDAO ucatbDAO = new UserCalendarArrangetbDAO();
            if (ucatbDAO.UpdateCalendarArrangeInfoById(caId, caTitle, caContent, caStartTime, caEndTime, caIntervalMinute, caType) == 1)
            {
                state = true;
            }
            return state;
        }

          /// <summary>
        /// 根据日程安排编号删除此日程安排信息
        /// </summary>
        /// <param name="caid"></param>
        /// <returns></returns>
        public bool delCalendarArrangeInfoById(int caid)
        {
            bool state = false;
            UserCalendarArrangetbDAO catbDAO = new UserCalendarArrangetbDAO();
            if (catbDAO.delCalendarArrangeInfoById(caid) == 1)
            {
                state = true;
            }
            return state;
        }

         /// <summary>
        /// 根据日程安排信息编号查看该日程安排信息
        /// </summary>
        /// <param name="caid"></param>
        /// <returns></returns>
        public UserCalendarArrangetb findByCaId(int caid)
        {
            UserCalendarArrangetbDAO ucatbDAO = new UserCalendarArrangetbDAO();
            return ucatbDAO.findByCaId(caid);
        }

         /// <summary>
        /// 返回当前用户的所有日程安排信息
        /// </summary>
        /// <param name="UserLoginName"></param>
        /// <returns></returns>
        public List<UserCalendarArrangetb> findAllByUserLoginName(string userLoginName)
        {
            UserCalendarArrangetbDAO ucatbDAO = new UserCalendarArrangetbDAO();
            return ucatbDAO.findAllByUserLoginName(userLoginName);
        }

         /// <summary>
        /// 根据当前用户和选择日期查找指定日期的所有日程安排信息
        /// </summary>
        /// <param name="UserLoginName"></param>
        /// <param name="curDate"></param>
        /// <returns></returns>
        public List<UserCalendarArrangetb> findCurDateAllByUserLoginNameAndCurDate(string userLoginName, DateTime curDate)
        {
            UserCalendarArrangetbDAO ucatbDAO = new UserCalendarArrangetbDAO();
            return ucatbDAO.findCurDateAllByUserLoginNameAndCurDate(userLoginName, curDate);
        }

        /// <summary>
        /// 查找指定日期内的日程安排信息
        /// </summary>
        /// <param name="dtStart"></param>
        /// <param name="dtEnd"></param>
        /// <returns></returns>
        public List<UserCalendarArrangetb> findAllBetweenStartAndEnd(string dtStart, string dtEnd, string type)
        {
            UserCalendarArrangetbDAO ucatbDAO = new UserCalendarArrangetbDAO();
            return ucatbDAO.findAllBetweenStartAndEnd(dtStart, dtEnd, type);
        }

    }
}
